package indi.gao.thread.callable;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import indi.gao.thread.service.BaseService;

import java.util.Date;
import java.util.Random;
import java.util.concurrent.Callable;

/**
 * @author :gaolei
 * @version :v1.0
 * @projectName :GLUtil
 * @description :
 * @createDate :2021/8/9 3:09 下午
 */
public class CallableTest implements Callable<String> {
    @Override
    public String call() {
        try {

            System.out.println("获取父类值："+BaseService.getInheritableThreadLocal());

            Random rand =new Random(100);
            int i=rand.nextInt(10000);
            Thread.sleep(i);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println(JSONObject.toJSONString(new Date(), SerializerFeature.WriteDateUseDateFormat) + Thread.currentThread().getName());
        return Thread.currentThread().getName();
    }
}
